package com.efast.dmom.mgmt.service.les.impl;

import java.util.Date;
import java.util.List;

import com.efast.cafe.framework.util.SpringWebUtils;
import com.efast.dmom.mgmt.dao.les.TrBasPartSupplPullDao;
import com.efast.dmom.mgmt.dao.master.TrBasPartSupplDao;
import com.efast.dmom.mgmt.entity.les.TrBasPartSupplPull;
import com.efast.dmom.mgmt.entity.master.TrBasPartSuppl;
import com.efast.dmom.mgmt.service.les.TrBasPartSupplPullService;
import com.efast.dmom.mgmt.utils.Assist;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class TrBasPartSupplPullServiceImpl implements TrBasPartSupplPullService {
	@Autowired
	private TrBasPartSupplPullDao trBasPartSupplPullDao;
	@Autowired
	private TrBasPartSupplDao trBasPartSupplDao;

	@Override
	public long getTrBasPartSupplPullRowCount(Assist assist) {
		return trBasPartSupplPullDao.getTrBasPartSupplPullRowCount(assist);
	}

	@Override
	public List<TrBasPartSupplPull> selectTrBasPartSupplPull(Assist assist) {
		return trBasPartSupplPullDao.selectTrBasPartSupplPull(assist);
	}

	@Override
	public TrBasPartSupplPull selectTrBasPartSupplPullByObj(TrBasPartSupplPull obj) {
		return trBasPartSupplPullDao.selectTrBasPartSupplPullByObj(obj);
	}

	@Override
	public TrBasPartSupplPull selectTrBasPartSupplPullById(Integer id) {
		return trBasPartSupplPullDao.selectTrBasPartSupplPullById(id);
	}

	@Override
	public int insertTrBasPartSupplPull(TrBasPartSupplPull value) {
		return trBasPartSupplPullDao.insertTrBasPartSupplPull(value);
	}

	@Override
	public int insertNonEmptyTrBasPartSupplPull(TrBasPartSupplPull value) {
		return trBasPartSupplPullDao.insertNonEmptyTrBasPartSupplPull(value);
	}

	@Override
	public int insertTrBasPartSupplPullByBatch(List<TrBasPartSupplPull> value) {
		return trBasPartSupplPullDao.insertTrBasPartSupplPullByBatch(value);
	}

	@Override
	public int deleteTrBasPartSupplPullById(Integer id) {
		return trBasPartSupplPullDao.deleteTrBasPartSupplPullById(id);
	}

	@Override
	public int deleteTrBasPartSupplPull(Assist assist) {
		return trBasPartSupplPullDao.deleteTrBasPartSupplPull(assist);
	}

	@Override
	public int updateTrBasPartSupplPullById(TrBasPartSupplPull enti) {
		return trBasPartSupplPullDao.updateTrBasPartSupplPullById(enti);
	}

	@Override
	public int updateTrBasPartSupplPull(TrBasPartSupplPull value, Assist assist) {
		return trBasPartSupplPullDao.updateTrBasPartSupplPull(value, assist);
	}

	@Override
	public int updateNonEmptyTrBasPartSupplPullById(TrBasPartSupplPull enti) {
		return trBasPartSupplPullDao.updateNonEmptyTrBasPartSupplPullById(enti);
	}

	@Override
	public int updateNonEmptyTrBasPartSupplPull(TrBasPartSupplPull value, Assist assist) {
		return trBasPartSupplPullDao.updateNonEmptyTrBasPartSupplPull(value, assist);
	}

	public TrBasPartSupplPullDao getTrBasPartSupplPullDao() {
		return this.trBasPartSupplPullDao;
	}

	public void setTrBasPartSupplPullDao(TrBasPartSupplPullDao trBasPartSupplPullDao) {
		this.trBasPartSupplPullDao = trBasPartSupplPullDao;
	}

	@Override
	public void saveSupplPull(TrBasPartSupplPull trBasPartSupplPull) {
		// 保存零件供应商配送模式
		TrBasPartSuppl partSuppl = trBasPartSupplDao.selectTrBasPartSupplById(trBasPartSupplPull.getTrBasPartSupplId());
		trBasPartSupplPull.setPlantNo(partSuppl.getPlantNo());
		trBasPartSupplPull.setWorkshopNo(partSuppl.getWorkshopNo());
		trBasPartSupplPull.setSupplNo(partSuppl.getSupplNo());
		trBasPartSupplPull.setPartNoVersion(partSuppl.getPartNoVersion());
		trBasPartSupplPull.setCompanyCode(SpringWebUtils.getRequestCompany());
		trBasPartSupplPull.setCreateTime(new Date());
		trBasPartSupplPull.setCreateUser(SpringWebUtils.getRequestUser());
		trBasPartSupplPullDao.insertTrBasPartSupplPull(trBasPartSupplPull);
	}

}